<?php
declare(strict_types=1);

namespace App;

use Swoole\Coroutine;

class Runtime
{
    public static function isMainThread(): bool
    {
        return \Swoole\Thread::getInfo()['is_main_thread'];
    }

    public static function getThreadId(): int
    {
        return \Swoole\Thread::getId();
    }

    public static function print(string $message, array $ctx = []): void
    {
        printf("Thread ID: [%d], Coroutine Id: [%d]: %s,%s\n", self::getThreadId(), Coroutine::getCid(), $message, json_encode($ctx));
    }


}